package org.forwhat.dao.Impl;

import org.forwhat.bean.WhatPostContent;
import org.forwhat.dao.WhatPostContentDao;
import org.forwhat.framework.annotation.Data;
import org.forwhat.framework.annotation.InsertBean;

/**
 * @projectName: ForWhat
 * @package: org.forwhat.dao.Impl
 * @className: WhatPostContentDaoImpl
 * @author: LGJ
 * @description: TODO
 * @date: 2023/12/2 9:20
 * @version: 1.0
 */

//@Data("WhatPostContentDaoImpl")
public class WhatPostContentDaoImpl extends BaseDaoImpl implements WhatPostContentDao {
    @InsertBean("BaseDaoImpl")
    private BaseDaoImpl baseDaoImpl;
    public BaseDaoImpl getBaseDaoImpl() {
        return baseDaoImpl;
    }

    public void setBaseDaoImpl(BaseDaoImpl baseDaoImpl) {
        this.baseDaoImpl = baseDaoImpl;
    }
    @Override
    public int insertPostContent(WhatPostContent whatPostContent) {

            return baseDaoImpl.update("insert into for_what.what_post_content value (?,?)",whatPostContent.getPostId(),whatPostContent.getPostContent());

    }

    @Override
    public WhatPostContent selectPostContentByPostId(String postId) {
        try {
            return baseDaoImpl.selectBean("select * from what_post_content where what_post_content.post_id = ?",WhatPostContent.class,postId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
